create or replace package body utl_submit_info as

function submit_information(
         param_name in varchar2,
         param_value in CLOB,
         req_url in varchar2
         )
   return varchar2 is
   
submit_result varchar2(100);
req utl_http.req ;
resp utl_http.resp;
content clob ;

begin
  select  RAWTOHEX(to_char(param_value)) into content from dual;
  content := param_name||'='||content;
  req := utl_http.begin_request(req_url,'POST',' HTTP/1.1');
  utl_http.set_header(req,'User-Agent','Mozilla/4.0');
  utl_http.set_header(req,'Content-type','application/x-www-form-urlencoded');
  utl_http.set_header(req, 'Content-Length', length(content));
  utl_http.write_text(req, content);
  dbms_output.put_line(content);
  resp := utl_http.get_response(req);
  utl_http.read_line(resp,submit_result,true);
  utl_http.end_response(resp);
  return submit_result;
exception
   when utl_http.end_of_body then 
        utl_http.end_response(resp);
        return 'ERROR';
end;  

function get_insert_node(
			node_name in char,
			node_value in char	
			)
	return clob is
	xml_str clob ;
begin
	if trim(node_value) is not null then
		xml_str:='<column name="'||node_name||'" value="'||trim(node_value)||'"/>';
		return trim(xml_str);
	else
		return '';
	end if;
end;

function get_delete_node(node_name in char)
	return clob is 
	xml_str clob ;
begin
	return null;
end;
	

	
function get_update_node(
		node_name in char,
		node_new_value in char,
		node_old_value in char
		)
	return clob is
xml_str clob ;
begin
	if trim(node_new_value) is not null then 
		xml_str:='<column name="'||node_name||'" value="'||trim(node_new_value)||'" old="'||trim(node_old_value)||'"/>';
		return trim(xml_str);
	else 
		return '';
	end if;
end;



end utl_submit_info;
/
show errors;
